package com.huipinche.view.impl;
import com.huipinche.view.*;
import com.huipinche.view.utils.*;

import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;

public class GeneralPageimpl implements SucceedPageView,WaitPageView{
    final int WIDTH = 500;
    final int HEIGHT = 400;


    public GeneralPageimpl(String text){
        initialize(text);
    }





    private void initialize(String txt){
        JFrame jFrame = new JFrame("慧拼车-提示页面");
        jFrame.setBounds((ScreenUtils.getScreenWidth() - WIDTH) / 2,
                (ScreenUtils.getScreenHeight() - HEIGHT) / 2, WIDTH, HEIGHT);
        jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);


        jFrame.getContentPane().setLayout(null);
        try {
            jFrame.setIconImage(ImageIO.read(new File(PathUtils.getRealPath("logo3.jpeg"))));
        } catch (IOException e) {
            e.printStackTrace();
        }

        Image image=new ImageIcon(PathUtils.getRealPath("bigbackground6.png")).getImage();
        BackGroundPanel bgPanel = new BackGroundPanel(image);
        bgPanel.setBounds(0,0,WIDTH,HEIGHT);

        JLabel lblNewLabel = new JLabel(txt);
        lblNewLabel.setFont(new Font("宋体", Font.PLAIN, 36));
        lblNewLabel.setBounds(77, 51, 400, 60);
        lblNewLabel.setForeground(Color.black);
        jFrame.getContentPane().add(lblNewLabel);
        jFrame.setVisible(true);

        Icon login = new ImageIcon((PathUtils.getRealPath("car3.png")));
        JButton btnNewButton = new JButton("返回");
        btnNewButton.setIcon(login);
        btnNewButton.addActionListener(new AbstractAction() {
            @Override
            public void actionPerformed(ActionEvent e) {
                //new loginPage()

                //this.removeNotify();
                jFrame.removeNotify();
            }
        });

        btnNewButton.setBounds(157, 153, 140, 33);
        jFrame.getContentPane().add(btnNewButton);
        jFrame.add(bgPanel);
    }

    /*public static void main(String[] args) {
        new GeneralPageimpl("登录成功");
    }*/
    @Override
    public int SucceedPage(boolean flag) {
        return 0;
    }

    @Override
    public int WaitPage(boolean flag) {
        return 0;
    }
}
